ADD UBRECORD (subfile; layout; *)
                                                               Pg 17-5

subfile      Subfile        Subfile to use for data entry
layout       String         Name of the layout to display
*                                Hide scroll bars and size box

ADD SUBRECORD lets the user add a new subrecord to subfile, using layout. ADD SUBRECORD creates a new subrecord in memory, makes it the current subrecord in the current process, and displays the layout. A current record for the parent file must first exist. If a current parent record does not exist for the process, ADD SUBRECORD has no effect. The layout must belong to subfile.

The subrecord is kept in memory (accepted) if the user clicks an Accept button or presses the Enter key, or if the  CCEPT command is executed. Accepting the subrecord sets the OK system variable to 1. Once the subrecord has been added or modified, the parent record must be explicitly saved in order for the subrecord to be saved (to disk).

The subrecord is not saved if the user clicks a Cancel button or presses the "Cancel" key combination (Command-period), or if the  ANCEL command is executed. Canceling sets the OK system variable to 0.

Subrecords are always added to the current parent record. If a subfile is within a subfile, make sure that the proper parent record (subrecord) is first selected.

The layout is displayed in a window with scroll bars and a size box. Specifying the optional asterisk (*) causes the window to be drawn without scroll bars or a size box.

The layout procedure execution cycle is started if a layout procedure exists for layout. Scripts that exist for layout may also be executed, depending on the user's actions. 

The following example is part of a global procedure. It adds a subrecord for a new child to an employees record. The data for the children is stored in a subfile named [Employees]Children. Notice that the [Employees] record must be saved in order for the new subrecord to be saved:

    ADD SUBRECORD([Employees]Children;"Add Child")
    If (OK=1)                                      ` If the user accepted subrecord
       SAVE RECORD([Employees])     ` save the [Employees] record
   End if

See also: MODIFY UBRECORD, SAVE ECORD